package com.changzhi.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.changzhi.common.constans.Constants;
import com.changzhi.common.constans.RedisConstans;
import com.changzhi.common.exception.ServiceException;
import com.changzhi.common.util.DateUtil;
import com.changzhi.common.util.TokenUtil;
import com.changzhi.ldyl.model.*;
import com.changzhi.ldyl.model.vo.StatusVo;
import com.changzhi.ldyl.model.vo.UserVo;
import com.changzhi.mapper.ActivityDayMapper;
import com.changzhi.mapper.ActivityPrizeMapper;
import com.changzhi.mapper.ActivityRecordMapper;
import com.changzhi.mapper.ActivityWalletMapper;
import com.changzhi.service.*;
import com.changzhi.util.CommonUtil;
import com.changzhi.util.RedisUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

/**
 * @Description:
 * @author: 小落
 * @date: 2021年04月19日
 */
@Slf4j
@Service
public class TanabataServiceImpl implements TanabataService {

	@Autowired
	private ActivityService activityService;
	@Autowired
	private UserService userService;
	@Autowired
	private RedisUtil redisUtil;
	@Resource
	private ActivityRecordMapper activityRecordMapper;
	@Autowired
	private GiftService giftService;
	@Resource
	private ActivityDayMapper activityDayMapper;
	@Resource
	private ActivityWalletMapper activityWalletMapper;
	@Resource
	private ActivityPrizeMapper activityPrizeMapper;
	private final ScheduledExecutorService executorService = Executors.newScheduledThreadPool(1);


	public static Map<String, LocalDateTime> TIME_MAP = new HashMap<>();
	public static Map<Integer, ActivityPrize> GIFT_MAP = new HashMap<>();
	public final static Integer ACTIVITY_ID = 29;


	@PostConstruct
	public void init(){
		redisUtil.del(RedisConstans.ACTIVITY + ACTIVITY_ID);
		Activity activity = activityService.getActivity(ACTIVITY_ID);
		List<ActivityPrize> allPrizeList = activityService.getPrizeList(ACTIVITY_ID, null);
		List<ActivityPrize> somePrizeList = allPrizeList.stream().filter(p -> p.getType() < 10).collect(Collectors.toList());
		for (ActivityPrize activityPrize : somePrizeList) {
			GIFT_MAP.put(activityPrize.getGiftId(), activityPrize);
		}
		/*//存奖品
		prizeList = allPrizeList.stream().filter(p -> p.getType() >= 10).collect(Collectors.toList());
		for (ActivityPrize prize : prizeList) {
			prize.setTotalValue(null).setStatus(null).setCreateTime(null).setNum(null).setRate(null).setActivityId(null).setId(null);
		}*/
		//存活动时间
		TIME_MAP.put("startTime", activity.getStartTime());
		TIME_MAP.put("endTime", activity.getEndTime());
	}

	public static void main(String[] args) {
		System.out.println(TokenUtil.createToken("1306872383956582400",1000));
	}

	@Override
	public void doMqDataByUserGift(UserGift userGift) {
		//1.是否在活动时间内
		if(!DateUtil.isBetweenTime(TIME_MAP.get("startTime"), TIME_MAP.get("endTime"))){
			//测试账号通行
			if(!CommonUtil.getTestAccountList().contains(userGift.getUserId())){
				return;
			}
		}
		//2.指定礼物
		if(GIFT_MAP.get(userGift.getGiftId()) == null){
			return;
		}
		String userId = userGift.getUserId();
		String targetId = userGift.getTargetId();
		Integer value = userGift.getTotalGiftValue() * 10;
		//3.插入记录
		ActivityRecord activityRecord = new ActivityRecord();
		activityRecord.setActivityId(ACTIVITY_ID);
		activityRecord.setType(0);
		activityRecord.setUserId(userId);
		activityRecord.setTargetUserId(targetId);
		activityRecord.setValue(value);
		activityRecord.setNum(userGift.getGiftCount());
		activityRecord.setGiftId(userGift.getGiftId());
		activityRecordMapper.insert(activityRecord);
		//4.增加送礼用户礼物值
		String key1 = RedisConstans.putRediskey(RedisConstans.ACTIVITY_FLAG, ACTIVITY_ID, userId);
		Integer id = redisUtil.get(key1);
		if (id == null) {
			ActivityWallet record = new ActivityWallet();
			record.setActivityId(ACTIVITY_ID);
			record.setUserId(userId);
			record.setAmount1(value);
			activityWalletMapper.insert(record);
			redisUtil.set(key1, record.getId(), RedisConstans.ONE_MONTH);
		} else{
			activityWalletMapper.addAmount1(id, value);
		}
		//5.增加收礼用户礼物值
		String key2 = RedisConstans.putRediskey(RedisConstans.ACTIVITY_FLAG, ACTIVITY_ID, targetId);
		Integer id2 = redisUtil.get(key2);
		if (id2 == null) {
			ActivityWallet record = new ActivityWallet();
			record.setActivityId(ACTIVITY_ID);
			record.setUserId(targetId);
			record.setAmount2(value);
			activityWalletMapper.insert(record);
			redisUtil.set(key2, record.getId(), RedisConstans.ONE_MONTH);
			id2 = record.getId();
		} else{
			activityWalletMapper.addAmount2(id2, value);
		}
		//6.增加日榜送礼用户礼物值
		LocalDate now = LocalDate.now();
		String key3 = RedisConstans.putRediskey(RedisConstans.ACTIVITY_FLAG, ACTIVITY_ID, userId, now.toString());
		Integer id3 = redisUtil.get(key3);
		if (id3 == null) {
			ActivityDay record = new ActivityDay();
			record.setActivityId(ACTIVITY_ID);
			record.setUserId(userId);
			record.setAmount1(value);
			record.setCreateDate(now);
			activityDayMapper.insert(record);
			redisUtil.set(key3, record.getId(), RedisConstans.ONE_MONTH);
		} else{
			activityDayMapper.addAmount1(id3, value);
		}
		//7.增加日榜收礼用户礼物值
		String key4 = RedisConstans.putRediskey(RedisConstans.ACTIVITY_FLAG, ACTIVITY_ID, targetId, now.toString());
		Integer id4 = redisUtil.get(key4);
		if (id4 == null) {
			ActivityDay record = new ActivityDay();
			record.setActivityId(ACTIVITY_ID);
			record.setUserId(targetId);
			record.setAmount2(value);
			record.setCreateDate(now);
			activityDayMapper.insert(record);
			redisUtil.set(key4, record.getId(), RedisConstans.ONE_MONTH);
			id4 = record.getId();
		} else{
			activityDayMapper.addAmount2(id4, value);
		}
		Integer finalId = id2;
		Integer finalDayId = id4;
		executorService.schedule(()->{
			try {
				Thread.sleep(500);
				//6.计算送礼最大礼物值
				String maxValueInfo = getMaxValueInfo(targetId);
				//7.修改最大用户数据
				ActivityWallet record = new ActivityWallet();
				record.setId(finalId);
				record.setProperty1(maxValueInfo);
				activityWalletMapper.updateById(record);
				//8.修改天最大用户数据
				ActivityDay activityDay = new ActivityDay();
				activityDay.setId(finalDayId);
				activityDay.setProperty1(getMaxValueDayInfo(targetId, now));
				activityDayMapper.updateById(activityDay);
				Thread.sleep(500);
				//7.删除钱包缓存
				redisUtil.del(RedisConstans.putRediskey(RedisConstans.WALLET, ACTIVITY_ID, userId));
				redisUtil.del(RedisConstans.putRediskey(RedisConstans.WALLET, ACTIVITY_ID, targetId));
				//8.删除排行榜缓存
				getRankingsByDb(null, now);
				//9.发放达到要求的奖励
				List<ActivityPrize> prizeList = getPrizeList();
				ActivityWallet wallet1 = activityWalletMapper.getWalletByUserId(ACTIVITY_ID, userId);
				if(wallet1 != null){
					Integer value1 = wallet1.getAmount1() > wallet1.getAmount2() ? wallet1.getAmount1() : wallet1.getAmount2();
					giveReward(prizeList, userId, value1);
				}
				ActivityWallet wallet2 = activityWalletMapper.getWalletByUserId(ACTIVITY_ID, targetId);
				if(wallet2 != null){
					Integer value2 = wallet2.getAmount1() > wallet2.getAmount2() ? wallet2.getAmount1() : wallet2.getAmount2();
					giveReward(prizeList, targetId, value2);
				}
			} catch(Exception e) {
				e.printStackTrace();
				log.error("methodName:doMqDataByUserGift,sweet,error={}", e.getMessage());
			}
		}, 1, TimeUnit.SECONDS);
	}

	//最多送礼值用户数据
	private String getMaxValueInfo(String targetId){
		Map<String, Object> map = new HashMap<>();
		ActivityRecord record = activityRecordMapper.selectMaxValueGroupByTargetId(ACTIVITY_ID, targetId);
		if(record != null){
			User user = userService.getUser(record.getUserId());
			if (user != null) {
				map.put("nickname", user.getNickname());
				map.put("avatarUrl", StringUtils.isBlank(user.getAvatarUrl()) ? Constants.DEFAULT_AVATAR : user.getAvatarUrl());
			}
			map.put("userId", record.getUserId());
			map.put("value", record.getValue());
		}
		return JSON.toJSONString(map);
	}

	//最多送礼值用户数据
	private String getMaxValueDayInfo(String targetId, LocalDate date){
		Map<String, Object> map = new HashMap<>();
		ActivityRecord record = activityRecordMapper.selectMaxValueDayByTargetId(ACTIVITY_ID, targetId, date);
		if(record != null){
			User user = userService.getUser(record.getUserId());
			if (user != null) {
				map.put("nickname", user.getNickname());
				map.put("avatarUrl", StringUtils.isBlank(user.getAvatarUrl()) ? Constants.DEFAULT_AVATAR : user.getAvatarUrl());
			}
			map.put("userId", record.getUserId());
			map.put("value", record.getValue());
		}
		return JSON.toJSONString(map);
	}

	private List<UserVo> getRankingsByDb(Integer type, LocalDate now){
		List<UserVo> list;
		if(type == null){
			//总榜
			list = activityWalletMapper.selectValue2Rankings(ACTIVITY_ID, 50);
			for (UserVo userVo : list) {
				if(StringUtils.isNotBlank(userVo.getProperty1())){
					JSONObject jsonObject = JSON.parseObject(userVo.getProperty1());
					userVo.setTargetNickname(jsonObject.getString("nickname"));
					userVo.setTargetAvatarUrl(jsonObject.getString("avatarUrl"));
					userVo.setTargetId(jsonObject.getString("userId"));
				}
				if(StringUtils.isBlank(userVo.getAvatarUrl())){
					userVo.setAvatarUrl(Constants.DEFAULT_AVATAR);
				}
			}
			redisUtil.set(RedisConstans.ACTIVITY_RANKING + ACTIVITY_ID + "_" + 0, list, RedisConstans.ONE_DAY);
			//日榜
			list = activityDayMapper.selectValue2Rankings(ACTIVITY_ID, now, 50);
			for (UserVo userVo : list) {
				if(StringUtils.isNotBlank(userVo.getProperty1())){
					JSONObject jsonObject = JSON.parseObject(userVo.getProperty1());
					userVo.setTargetNickname(jsonObject.getString("nickname"));
					userVo.setTargetAvatarUrl(jsonObject.getString("avatarUrl"));
					userVo.setTargetId(jsonObject.getString("userId"));
				}
				if(StringUtils.isBlank(userVo.getAvatarUrl())){
					userVo.setAvatarUrl(Constants.DEFAULT_AVATAR);
				}
			}
			redisUtil.set(RedisConstans.ACTIVITY_RANKING + ACTIVITY_ID + "_" + 1 + now.toString(), list, RedisConstans.ONE_DAY);
		} else if(type == 0){
			//总榜
			list = activityWalletMapper.selectValue2Rankings(ACTIVITY_ID, 50);
			for (UserVo userVo : list) {
				if(StringUtils.isNotBlank(userVo.getProperty1())){
					JSONObject jsonObject = JSON.parseObject(userVo.getProperty1());
					userVo.setTargetNickname(jsonObject.getString("nickname"));
					userVo.setTargetAvatarUrl(jsonObject.getString("avatarUrl"));
					userVo.setTargetId(jsonObject.getString("userId"));
				}
				if(StringUtils.isBlank(userVo.getAvatarUrl())){
					userVo.setAvatarUrl(Constants.DEFAULT_AVATAR);
				}
			}
			redisUtil.set(RedisConstans.ACTIVITY_RANKING + ACTIVITY_ID + "_" + type, list, RedisConstans.ONE_DAY);
		} else {
			//日榜
			list = activityDayMapper.selectValue2Rankings(ACTIVITY_ID, now, 50);
			for (UserVo userVo : list) {
				if(StringUtils.isNotBlank(userVo.getProperty1())){
					JSONObject jsonObject = JSON.parseObject(userVo.getProperty1());
					userVo.setTargetNickname(jsonObject.getString("nickname"));
					userVo.setTargetAvatarUrl(jsonObject.getString("avatarUrl"));
					userVo.setTargetId(jsonObject.getString("userId"));
				}
				if(StringUtils.isBlank(userVo.getAvatarUrl())){
					userVo.setAvatarUrl(Constants.DEFAULT_AVATAR);
				}
			}
			redisUtil.set(RedisConstans.ACTIVITY_RANKING + ACTIVITY_ID + "_" + type + now.toString(), list, RedisConstans.ONE_DAY);
		}
		return list;
	}

	private ActivityWallet getWalletInfo(String userId){
		String key = RedisConstans.putRediskey(RedisConstans.WALLET, ACTIVITY_ID, userId);
		ActivityWallet wallet = redisUtil.get(key);
		if(wallet != null){
			return wallet;
		}
		LambdaQueryWrapper< ActivityWallet> wrapper = new LambdaQueryWrapper<>();
		wrapper.eq(ActivityWallet::getActivityId, ACTIVITY_ID).eq(ActivityWallet::getUserId, userId);
		wallet = activityWalletMapper.selectOne(wrapper);
		if (wallet == null) {
			wallet = new ActivityWallet();
			wallet.setUserId(userId);
			wallet.setAmount1(0);
			wallet.setAmount2(0);
		}
		redisUtil.set(key, wallet, RedisConstans.ONE_HOUR);
		return wallet;
	}

	@Override
	public Map<String, Object> rankings(String userId, Integer type) {
		if(type == null){
			throw new ServiceException("类型不能为空");
		}
		LocalDate now = LocalDate.now();
		Map<String, Object> result = new HashMap<>();
		String key;
		if(type == 0){//总榜
			key = RedisConstans.ACTIVITY_RANKING + ACTIVITY_ID + "_" + type;
		} else {//天榜
			key = RedisConstans.ACTIVITY_RANKING + ACTIVITY_ID + "_" + type + now.toString();
		}
		//排行榜
		List<UserVo> list = redisUtil.get(key);
		if(CollectionUtils.isEmpty(list)){
			list = getRankingsByDb(type, now);
		}
		int rank = 1;
		int previousValue = 0;
		UserVo userVo = new UserVo();
		for (UserVo vo : list) {
			vo.setRank(rank).setProperty1(null);
			if(userId.equals(vo.getUserId())){
				userVo.setRank(rank).setTargetId(vo.getTargetId());
				if(rank != 1){
					userVo.setDiffValue(previousValue - vo.getValue());
					if(userVo.getDiffValue() == 0){
						userVo.setDiffValue(1);
					}
				}
			}
			previousValue = vo.getValue();
			rank++;
		}
	/*	// TODO: 2021/8/6
		for (int i = 0; i < 5; i++) {
			list.addAll(list);
		}*/
		User user = userService.getUser(userId);
		if(type == 0) {//总榜
			//个人信息
			ActivityWallet wallet = getWalletInfo(userId);
			JSONObject jsonObject = new JSONObject();
			if(StringUtils.isNotBlank(wallet.getProperty1())){
				jsonObject = JSON.parseObject(wallet.getProperty1());
			}
			userVo.setUserId(user.getUserId())
					.setAccountId(user.getAccountId())
					.setNickname(user.getNickname())
					.setAvatarUrl(StringUtils.isBlank(user.getAvatarUrl()) ? Constants.DEFAULT_AVATAR : user.getAvatarUrl())
					//若在对应榜单上则显示实际名次“1-50”距上一名还差xxx；若未上榜则显示“未上榜”，距上榜还差xxx。
					.setTargetNickname(jsonObject.getString("nickname"))
					.setTargetAvatarUrl(jsonObject.getString("avatarUrl"))
					.setProperty1(null)
					.setTargetValue(jsonObject.getInteger("value") == null ? 0 : jsonObject.getInteger("value"))
					.setTargetId(jsonObject.getString("userId"))
					.setValue(wallet.getAmount2());
			if(userVo.getDiffValue() == null){
				userVo.setDiffValue(previousValue - (wallet == null ? 0 : wallet.getAmount2()));
			}
		} else {
			LambdaQueryWrapper<ActivityDay> wrapper = new LambdaQueryWrapper<>();
			wrapper.eq(ActivityDay::getActivityId,ACTIVITY_ID ).eq(ActivityDay::getUserId, userId).eq(ActivityDay::getCreateDate, now);
			ActivityDay activityDay = activityDayMapper.selectOne(wrapper);
			if(activityDay == null){
				activityDay = new ActivityDay();
				activityDay.setUserId(userId);
				activityDay.setAmount1(0);
				activityDay.setAmount2(0);
			}
			JSONObject jsonObject = new JSONObject();
			if(StringUtils.isNotBlank(activityDay.getProperty1())){
				jsonObject = JSON.parseObject(activityDay.getProperty1());
			}
			userVo.setUserId(user.getUserId())
					.setAccountId(user.getAccountId())
					.setNickname(user.getNickname())
					.setAvatarUrl(StringUtils.isBlank(user.getAvatarUrl()) ? Constants.DEFAULT_AVATAR : user.getAvatarUrl())
					//若在对应榜单上则显示实际名次“1-50”距上一名还差xxx；若未上榜则显示“未上榜”，距上榜还差xxx。
					.setTargetNickname(jsonObject.getString("nickname"))
					.setTargetAvatarUrl(jsonObject.getString("avatarUrl"))
					.setProperty1(null)
					.setTargetValue(jsonObject.getInteger("value") == null ? 0 : jsonObject.getInteger("value"))
					.setTargetId(jsonObject.getString("userId"))
					.setValue(activityDay.getAmount2());
			if(userVo.getDiffValue() == null){
				userVo.setDiffValue(previousValue - activityDay.getAmount2());
			}
		}
		if(userVo.getRank() == null){
			userVo.setRank(-1);
		}
		//返回
		result.put("ranking", list);
		result.put("self", userVo);
		return result;
	}

	@Override
	public Map<String, Object> task(String userId) {
		Map<String, Object> result = new HashMap<>();
		//个人信息
		User user = userService.getUser(userId);
		ActivityWallet wallet = getWalletInfo(userId);
		//任务列表
		List<StatusVo> list = new ArrayList<>();
		list.add(new StatusVo("5W", (wallet.getAmount1() >= 50000 || wallet.getAmount2() >= 50000) ? 1 : 0));
		list.add(new StatusVo("20W", (wallet.getAmount1() >= 200000 || wallet.getAmount2() >= 200000) ? 1 : 0));
		list.add(new StatusVo("50W", (wallet.getAmount1() >= 500000 || wallet.getAmount2() >= 500000) ? 1 : 0));
		list.add(new StatusVo("100W", (wallet.getAmount1() >= 1000000 || wallet.getAmount2() >= 1000000) ? 1 : 0));
		list.add(new StatusVo("200W", (wallet.getAmount1() >= 2000000 || wallet.getAmount2() >= 2000000) ? 1 : 0));
		//返回
		result.put("userId", user.getUserId());
		result.put("accountId", user.getAccountId());
		result.put("nickname", user.getNickname());
		result.put("avatarUrl", StringUtils.isBlank(user.getAvatarUrl()) ? Constants.DEFAULT_AVATAR : user.getAvatarUrl());
		result.put("value", wallet.getAmount2());
		result.put("targetValue", wallet.getAmount1());
		result.put("taskList", list);
		return result;
	}

	//发放奖励
	private void giveReward(List<ActivityPrize> prizeList, String userId, long totalValue){
		if(totalValue >= 50000){
			ActivityPrize prize = prizeList.stream().filter(p -> p.getType() == 11).collect(Collectors.toList()).get(0);
			savePrize(prize, userId);
		}
		if(totalValue >= 100000){
			ActivityPrize prize = prizeList.stream().filter(p -> p.getType() == 12).collect(Collectors.toList()).get(0);
			savePrize(prize, userId);
		}
		if(totalValue >= 500000){
			ActivityPrize prize = prizeList.stream().filter(p -> p.getType() == 13).collect(Collectors.toList()).get(0);
			savePrize(prize, userId);
		}
		if(totalValue >= 1000000){
			ActivityPrize prize = prizeList.stream().filter(p -> p.getType() == 14).collect(Collectors.toList()).get(0);
			savePrize(prize, userId);
		}
		if(totalValue >= 2000000) {
			ActivityPrize prize = prizeList.stream().filter(p -> p.getType() == 15).collect(Collectors.toList()).get(0);
			savePrize(prize, userId);
		}
	}

	private void savePrizeDay(ActivityPrize prize, String userId){
		if(prize.getSource() == 2){
			giftService.saveUserDress(ACTIVITY_ID, userId, prize.getGiftId(), 31, 1, "七夕活动天榜获得");
		} else {
			giftService.savePrize(ACTIVITY_ID, userId, prize.getGiftId(), 30, 1);
		}
	}


	//保存奖品
	@Override
	public void savePrize(ActivityPrize prize, String userId){
		String key = RedisConstans.putRediskey(RedisConstans.ACTIVITY_PRIZE_RECORD, ACTIVITY_ID, prize.getType(), userId);
		if(redisUtil.get(key) != null){
			return;
		}
		if(prize.getSource() == 2){
			giftService.saveUserDress(ACTIVITY_ID, userId, prize.getGiftId(), 31, 1, "七夕活动获得");
		} else {
			giftService.savePrize(ACTIVITY_ID, userId, prize.getGiftId(), 30, 1);
		}
		redisUtil.set(key, 1, RedisConstans.ONE_MONTH);
	}

	@Override
	public void givePrize() {
		List<ActivityPrize> prizeList = getPrizeList();
		LocalDate yesterday = LocalDate.now().minusDays(1L);
		//发放昨天收礼日榜奖励
		List<UserVo> list = activityDayMapper.selectValue2Rankings(ACTIVITY_ID, yesterday, 10);
		int num = 1;
		for (UserVo userVo : list) {
			String targetId = null;
			if(StringUtils.isNotBlank(userVo.getProperty1())){
				JSONObject jsonObject = JSON.parseObject(userVo.getProperty1());
				targetId = jsonObject.getString("userId");
			}
			//前3名
			if(num <= 3){
				ActivityPrize prize = prizeList.stream().filter(p -> p.getType() == 22).collect(Collectors.toList()).get(0);
				savePrizeDay(prize, userVo.getUserId());
				if(StringUtils.isNotBlank(targetId)){
					savePrizeDay(prize, targetId);
				}
			}
			//前10名
			ActivityPrize prize1 = prizeList.stream().filter(p -> p.getType() == 20).collect(Collectors.toList()).get(0);
			savePrizeDay(prize1, userVo.getUserId());
			if(StringUtils.isNotBlank(targetId)){
				ActivityPrize prize2 = prizeList.stream().filter(p -> p.getType() == 21).collect(Collectors.toList()).get(0);
				savePrizeDay(prize2, targetId);
			}
			num++;
		}
		/*//发放昨天送礼日榜奖励
		list = activityDayMapper.selectValue1Rankings(ACTIVITY_ID, yesterday, 10);
		num = 1;
		for (UserVo userVo : list) {
			//前3名
			if(num <= 3){
				ActivityPrize prize = prizeList.stream().filter(p -> p.getType() == 22).collect(Collectors.toList()).get(0);
				savePrize(prize, userVo.getUserId(), yesterday, 1);
			}
			//前10名
			ActivityPrize prize1 = prizeList.stream().filter(p -> p.getType() == 21).collect(Collectors.toList()).get(0);
			savePrize(prize1, userVo.getUserId(), yesterday, 1);
			num++;
		}*/
	}

	private List<ActivityPrize> getPrizeList(){
		LambdaQueryWrapper<ActivityPrize> wrapper = new LambdaQueryWrapper<>();
		wrapper.eq(ActivityPrize::getActivityId, ACTIVITY_ID).eq(ActivityPrize::getStatus, 1).ge(ActivityPrize::getType, 10);
		List<ActivityPrize> prizeList = activityPrizeMapper.selectList(wrapper);
		return prizeList;
	}
}
